/**
 *    Copyright (C) 2008, 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_API_COLLECTIONS_CTREE_HPP
#define	_CUBEFS_API_COLLECTIONS_CTREE_HPP

#include <cubefs/api/models/dyn_vector.hpp>

namespace cubefs    {
namespace api       {

struct CTreeType {
    enum {LOUDS, DFUDS};
};
CUBEFS_DECLARE_TYPENAME(CTreeType,    "cubefs::api::models::CTreeType");


struct CUBEFS_API CTreeLabel: public Data {
	static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(CTreeLabel,    "cubefs::api::models::CTreeLabel");

struct CUBEFS_API CTreePathSet: public Data {
	static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(CTreePathSet,    "cubefs::api::models::CTreePathSet");

struct CUBEFS_API CTreeIterator: public DataIterator {

    virtual void Root()                         = 0;
    virtual bool Parent()                       = 0;

    virtual bool NextChild()                    = 0;
    virtual bool PrevChild()                    = 0;

    virtual bool NextSibling()                  = 0;
    virtual bool PrevSibling()                  = 0;

    virtual bool Child(CTreeLabel* label)       = 0;
    virtual bool Child(BigInt index)            = 0;

    virtual BigInt GetChildIndex()              = 0;
    virtual BigInt GetSubtreeSize()             = 0;
    virtual BigInt GetChildrenCount()           = 0;

    virtual void GetLabel(CTreeLabel* label)    = 0;
    virtual bool GetNodeData(Typed* holder)     = 0;

    virtual void Insert(CTreePathSet* paths)    = 0;
    virtual bool Remove(CTreePathSet* paths)    = 0;

    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(CTreeIterator,    "cubefs::api::models::CTreeIterator");


struct CUBEFS_API CTree: public DynVector {

    virtual Int GetCTreeType()                                      = 0;
    virtual CTreeIterator* GetRoot()                                = 0;

    virtual CTreePathSet* CreateSimplePath(Int length)              = 0;
    virtual Typed* CreateNodeDataHolder()                           = 0;
    virtual CTreeLabel* CreateLabelHolder()                         = 0;

    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(CTree,    "cubefs::api::models::CTree");

}
}



#endif
